<template>
	<view>
		<u-navbar :is-back="true" title="添加分组" title-color="white" :background="{backgroundColor: '#00a8ff'}">
			<view class="navbar-right" slot="right">
				<view class="" style="margin-right: 20rpx;color: #FFFFFF;" @click="save()">
					保存
				</view>
			</view>
		</u-navbar>
		
		<view class="u-p-26 coBg u-m-b-26">
			<p>分组名称</p>
			<u-input v-model="value" :type="type" placeholder="请输入组名" :border="border" :clearable="false" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				type: 'text',
				border: false
			}
		},
		methods: {
			// 保存操作
			save(){
				console.log("保存操作");
				this.addGroup();
				setTimeout(()=>{
					uni.navigateBack()
				},1000)
				
			},
			addGroup(){
				if(this.value=='') return;
				this.$apiCase.quIadd({
					title:this.value
				}).then((res) => {
					console.log("res.data: ", res.data.code);
					uni.showToast({
						title:"新增成功"
					})
				}).catch((err) => {
					console.log('request fail', err);
				})
			}
		}
	}
</script>